package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.ProductClassify;
import cn.wolfcode.crm.mapper.ProductClassifyMapper;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IProductClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductClassifyServiceImpl implements IProductClassifyService {

    @Autowired
    private ProductClassifyMapper productClassifyMapper;

    public void insert(ProductClassify entity) {
        productClassifyMapper.insert(entity);
    }

    public void delete(Long id) {
        productClassifyMapper.deleteByPrimaryKey(id);
    }

    public void update(ProductClassify entity) {
        productClassifyMapper.updateByPrimaryKey(entity);
    }

    public ProductClassify get(Long id) {
        return productClassifyMapper.selectByPrimaryKey(id);
    }

    public List<ProductClassify> list() {
        return productClassifyMapper.selectAll();
    }

    public PageResult query(QueryObject qo) {
        int total = productClassifyMapper.queryForCount(qo);
        List<ProductClassify> rows = productClassifyMapper.queryForList(qo);
        return new PageResult(total,rows);
    }

    public List<ProductClassify> queryBoot() {
        return productClassifyMapper.queryBoot();
    }

    public List<ProductClassify> queryChildByParentId(Long parentId) {
        return productClassifyMapper.queryChildByParentId(parentId);
    }
}
